define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'cost.company/index',
        add_url: 'cost.company/add',
        edit_url: 'cost.company/edit',
        delete_url: 'cost.company/delete',
        export_url: 'cost.company/export',
        download_tpl_url: 'cost.company/downloadTpl',

    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                toolbar:['refresh', 'add', 'delete','export','download_tpl','upload'],
                cols: [[
                    {type: "checkbox"},
                    {field: 'id', width: 80, title: 'ID'},
                    {field: 'company_name', minWidth: 80, title: '城市化分'},
                    {field: 'remark', minWidth: 80, title: '备注信息'},
                    {field: 'create_time', minWidth: 80, title: '创建时间', search: 'range'},
                    {width: 250, title: '操作', templet: ea.table.tool}
                ]],
            });
            var upload = layui.upload;
            upload.render({
                elem: '#upload_file'
                ,url: 'uploadFile'
                ,before: function(obj){ //obj参数包含的信息，跟 choose回调完全一致，可参见上文。
                    layer.load(); //上传loading
                }
                ,done: function(res, index, upload){ //上传后的回调
                    ea.msg.success(res.msg)
                    layer.closeAll('loading'); //关闭loading
                    window.location.reload(); //刷新当前页面.
                }
                ,accept: 'file' //允许上传的文件类型
                ,exts:'xls|xlsx'
                ,error: function(){
                    ea.msg.error(res.msg)
                    layer.closeAll('loading'); //关闭loading
                }
            })

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
    };
    return Controller;
});